/**
 * 
 */
package com.thor.palmmall.rest.meter.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.meter.APeriodValues;
import com.thor.palmmall.spi.meter.SPeriodValues;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class APeriodValuesConverter implements Converter<SPeriodValues, APeriodValues> {

  public static APeriodValuesConverter getInstance() {
    if (instance == null)
      instance = new APeriodValuesConverter();
    return instance;
  }

  private static APeriodValuesConverter instance;

  private APeriodValuesConverter() {
  }

  @Override
  public APeriodValues convert(SPeriodValues source) {
    if (source == null) {
      return null;
    }
    APeriodValues target = new APeriodValues();
    target.setMeterPeriodType(source.getMeterPeriodType());
    target.setMultiply(source.getMultiply());
    target.setLastValue(AMeterValueConverter.getInstance().convert(source.getLastValue()));
    return target;
  }

}
